//
//  ViewController.m
//  1.简易动画（兔子跳）
//
//  Created by student on 16/2/19.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    NSMutableArray *marr=[[NSMutableArray alloc]init];
    
    for (int i=1; i<=20; i++) {
        NSString *picName=[NSString stringWithFormat:@"frame-%i.png",i];
        UIImage *image=[UIImage imageNamed:picName];
        [marr addObject:image];
        
        self.imageView.animationImages=marr;
        self.imageView.animationDuration=2;
        [self.imageView startAnimating];
        
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)btnPressed:(id)sender {
    if (self.imageView.isAnimating) {
        [self.imageView stopAnimating];
        [self.button setTitle:@"跳" forState:UIControlStateNormal];
    }else
    {
        [self.imageView startAnimating];
        [self.button setTitle:@"停" forState:UIControlStateNormal];
    }
}

- (IBAction)changed:(UISlider *)sender {
    
    self.imageView.animationDuration=2-sender.value;
    
    if ([self.imageView isAnimating]) {
        [self.imageView startAnimating];
    }
}
@end
